package com.chushouya.controller.manager.api;


import com.chushouya.common.annotations.AuthSkip;
import com.chushouya.common.constant.ServiceType;
import com.chushouya.manager.dto.admin.article.ArticleApiDetailDTO;
import com.chushouya.manager.dto.admin.article.ArticleApiListDTO;
import com.chushouya.manager.dto.admin.article.ArticleApiQuery;
import com.chushouya.manager.service.api.ArticleApiService;
import com.general.framework.core.schema.PageResult;
import com.general.framework.core.schema.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags = ServiceType.API + "文章列表")
@RestController
@RequestMapping(ServiceType.API + "/article")
public class ArticleApiController {
    @Resource
    private ArticleApiService articleApiService;

    @GetMapping("/search")
    @ApiOperation("新闻列表")
    @AuthSkip
    public Response<PageResult<ArticleApiListDTO>> search(ArticleApiQuery query) {
        return Response.success(articleApiService.selectPage(query));
    }

    @GetMapping("/detail")
    @ApiOperation("新闻详情")
    @ApiImplicitParam(name = "articleId", value = "文章ID", required = true)
    @AuthSkip
    public Response<ArticleApiDetailDTO> detail(Long articleId) {
        return Response.success(articleApiService.detail(articleId));
    }

}
